import requests
import json
import  time
import jwt
ak = "0198A7F7EB6B7ACBA1A94BB0B09B5285"
sk = "0198A7F7EB6B7AC0890AEDE85B143489"
def encode_jwt_token(ak, sk):
    headers = {
        "alg": "HS256",
        "typ": "JWT"
    }
    payload = {
        "iss": ak,
        "exp": int(time.time()) + 1800, # 有效时间，此处示例代表当前时间+1800s(30min)
        "nbf": int(time.time()) - 5 # 开始生效的时间，此处示例代表当前时间-5秒
    }
    token = jwt.encode(payload, sk, headers=headers)
    return token
#获取生成的API_TOKEN
authorization = encode_jwt_token(ak, sk)
print(authorization)
url='https://mhapi.sensetime.com/v1/imgenstd/models'
headers = {
    'Content-Type': 'application/json',
    'Authorization': f'Bearer {authorization}'
           }
response = requests.request("GET", url, headers=headers)
print(response.text)